package com.qkl.xiatang.app.dto.message;

import com.qkl.xiatang.app.utils.AppUtils;
import com.qkl.xiatang.app.utils.appenum.MessageTypeEnum;
import lombok.Data;
import org.apache.commons.lang3.ObjectUtils;

import java.util.ArrayList;
import java.util.List;

@Data
public class MessagePushUserDTO {

    private String messageId;

    private Integer subType;

    private Integer cnt;

    private String companyId;

    private Integer feed;

    private Integer weigh;

    private Integer administer;

    private Integer alloc;

    private Integer checked;

    private Integer holder;

    private Integer observe;

    private List<String> feedList;

    private List<String> weighList;

    private List<String> adminList;

    private List<String> allocList;

    private List<String> checkList;

    private List<String> holderList;

    private List<String> observeList;


    public List<String> getCids(MessageTypeEnum typeEnum){
        List<String> list = this.getCids1(typeEnum);
        if(ObjectUtils.isEmpty(list)){
            list = new ArrayList<>();
        }
        addAllList(list,adminList);
        addAllList(list,holderList);
        addAllList(list,observeList);
        addAllList(list,allocList);
        list = AppUtils.stringsDistinct(list);
        return list;
    }

    public List<String> getCids1(MessageTypeEnum typeEnum){
        if(typeEnum == MessageTypeEnum.WEIGH_FEED || typeEnum == MessageTypeEnum.WEIGH_ZOO){
            return weighList;
        }else if(typeEnum == MessageTypeEnum.FEED || typeEnum == MessageTypeEnum.ZOO){
            return feedList;
        }else if(typeEnum == MessageTypeEnum.CHECK){
            return checkList;
        }
        return null;
    }

    private static void addAllList(List<String> scrList,List<String>  addList){
        if( null != scrList && !ObjectUtils.isEmpty(addList)){
            scrList.addAll(addList);
        }
    }

}
